package com.example.smartcity_poverty.ui.SmartSubject.AllSubjectActivity.PovertyActivity.fragment.poverty.adapter

import android.content.Intent
import com.example.smartcity_poverty.Base.BaseRecyclerAdapter
import com.example.smartcity_poverty.ui.SmartSubject.AllSubjectActivity.PovertyActivity.fragment.poverty.activity.RhActivity
import com.example.smartcity_poverty.ui.SmartSubject.AllSubjectActivity.PovertyActivity.fragment.poverty.model.PtHotEntity
import kotlinx.android.synthetic.main.re_item_poverty_hot.*

/**
 *  created by ikun
 *  ANDROID STUDIO - version 4.0
 *  email: jinkunwei41@gmail.com
 * --------------------------------
 *  入户走访模块适配器
 **/
class PtHotAdapter (
    val list: MutableList<PtHotEntity>,
    val layoutId: Int
) : BaseRecyclerAdapter<PtHotEntity>(list, layoutId){
    override fun setData(
        view: BaseViewHolder.ViewFind,
        data: PtHotEntity,
        position: Int,
        holder: BaseViewHolder
    ) {

        if (list.size <= 0){

        }else{
            val d = list[position]
            holder.viewFind.poverty_hotImage.setImageResource(d.ptHotImage)
            holder.viewFind.poverty_hotTitle.text = d.ptHotContent

            val con = holder.viewFind.view?.context
            holder.itemView.setOnClickListener {
                if (holder.viewFind.poverty_hotTitle.text.toString() == "汝南县板店乡：精准扶贫 入户走访暖人心")
                    con?.startActivity(Intent(con, RhActivity::class.java).putExtra("id", "1"))
                if (holder.viewFind.poverty_hotTitle.text.toString() == "精准扶贫零距离 入户走访暖人心")
                    con?.startActivity(Intent(con, RhActivity::class.java).putExtra("id", "2"))
            }
        }

    }

}